//
//  SGSAboutTableViewController.m
//  RapidSquare
//
//  Created by German on 19.08.14.
//  Copyright (c) 2014 Softlegion. All rights reserved.
//

#import "SGSAboutTableViewController.h"

@interface SGSAboutTableViewController ()

@end

@implementation SGSAboutTableViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
}

- (IBAction)onMainWebSiteButtonClick:(id)sender {
    NSString* urlString = self.btnMainWebSite.titleLabel.text;
    
    NSRange prefixRange = [urlString rangeOfString:@"http"
                                           options:(NSAnchoredSearch | NSCaseInsensitiveSearch)];
    
    if (prefixRange.location == NSNotFound) {
        urlString = [NSString stringWithFormat:@"http://%@",urlString];
    }
    
    urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString: urlString];
    
    if (![[UIApplication sharedApplication] openURL:url]) {
        NSLog(@"%@%@",@"Failed to open url:",[url description]);
    }
}

@end
